package org_rosjava.ros.android.android_tutorial_map_viewer;
import java.util.*;
public class sortdemon2 {
    public static String[] sortArray(String str[]){
        ArrayList<Integer> list = new ArrayList<>();
        for (String s : str) {
            Scanner scanner = new Scanner(s);
            while (scanner.hasNextInt())
                list.add(scanner.nextInt());
            scanner.close();
        }
        Integer[] ia = list.toArray(new Integer[0]);
        int result[] = new int[ia.length];
        for (int i = 0; i < result.length; i++) {
            result[i] = ia[i];
        }
        Arrays.sort(result);
        String[] subInt = new String[result.length];
        for (int i = 0; i < result.length; i++) {
            subInt[i] = String.valueOf(result[i]);
        }
        System.out.println("str: "+Arrays.toString(str));
        System.out.println("subInt: "+Arrays.toString(subInt));
        String subStr[] =new String[str.length];
        ArrayList c = new ArrayList();
        for (int i = 0; i < str.length; i++) {
            for (int j = 0; j < subInt.length; j++) {
                if (str[i].equals(subInt[j])) {
                    c.add(str[i]);
                }
            }
        }
        System.out.print("subStr：");
        int i=0;
        for (int j = 0; j < str.length; j++) {
            if (!c.contains(str[j])) {

                subStr[i++] = str[j];
            }
        }
        System.out.println(Arrays.toString(subStr));
        int j=0;
        for(String s:subStr){
            if(s!=null){
                j++;
            }
        }
        System.out.println(j);
        String subStr2[] = new String[j];
        for(i=0;i<j;i++){
            subStr2[i] = subStr[i];
        }
        Arrays.sort(subStr2);
        System.out.println(Arrays.toString(subStr2));
        String finalResult[] = new String[str.length];
        System.arraycopy(subInt, 0, finalResult, 0, subInt.length);
        System.arraycopy(subStr2, 0, finalResult, subInt.length, subStr2.length);
        System.out.println(Arrays.toString(finalResult));
        return finalResult;
    }
}
